﻿namespace WMS6.Web.Inventory
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.InventoryMgtServiceRef;
    using WMS6.Web.UserControls;

    public class InventoryList : BasePage
    {
        protected Button btnExport;
        protected Button btnGoBack;
        private Dictionary<string, string> dicColum = null;
        private Dictionary<string, string> dicColum2 = null;
        private Dictionary<string, string> dicColum3 = null;
        protected HtmlForm F5012;
        protected GridView gvInventory;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdnFrom;
        private Hashtable hstable = null;
        protected Label lblMsg;
        protected Label lblReceiptInquiryList;
        protected HtmlLink mycss;
        protected Pager PagerFooter;
        protected ScriptManager ScriptManager1;

        private void BindData2InventoryList(InventoryQueryEntity inventoryQuery)
        {
            try
            {
                this.PagerFooter.CurrentPage = int.Parse(inventoryQuery.CurrentPage);
                DataSet ds = InventoryMgtServiceClientProxy.GetInstance().GetInventroyByQueryEnetiy(inventoryQuery);
                if (ds != null)
                {
                    if (this.gvInventory.Columns != null)
                    {
                        this.gvInventory.Columns.Clear();
                    }
                    BoundField bfSeqNo = new BoundField {
                        HeaderText = (base.UserInfo.Preference.Lang.ToLower() == "zh-cn") ? "序号" : "No"
                    };
                    bfSeqNo.ItemStyle.CssClass = "GridViewRowWidth_40";
                    this.gvInventory.Columns.Add(bfSeqNo);
                    TemplateField tfChkbox = new TemplateField {
                        ShowHeader = true,
                        HeaderTemplate = new MyHeaderTemplate(DataControlRowType.Header, ""),
                        ItemTemplate = new MyHeaderTemplate(DataControlRowType.DataRow, "")
                    };
                    tfChkbox.HeaderStyle.CssClass = "GridViewRowWidth_40";
                    tfChkbox.ItemStyle.CssClass = "GridViewRowWidth_40";
                    tfChkbox.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                    tfChkbox.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                    this.gvInventory.Columns.Add(tfChkbox);
                    int gvWidth = 80;
                    for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                    {
                        string temp = this.GetStrByDicKey(ds.Tables[0].Columns[i].ColumnName);
                        BoundField bf = new BoundField();
                        if ((temp != "") && (temp != "货品描述"))
                        {
                            bf.HeaderText = temp;
                            bf.HeaderStyle.CssClass = "GridViewRowWidth_150";
                            bf.ItemStyle.CssClass = "GridViewRowWidth_150";
                            bf.DataField = ds.Tables[0].Columns[i].ColumnName;
                            gvWidth += 150;
                            this.gvInventory.Columns.Add(bf);
                        }
                        else if (temp == "货品描述")
                        {
                            bf.HeaderText = temp;
                            bf.HeaderStyle.CssClass = "GridViewRowWidth_250";
                            bf.ItemStyle.CssClass = "GridViewRowWidth_250";
                            bf.DataField = ds.Tables[0].Columns[i].ColumnName;
                            gvWidth += 250;
                            this.gvInventory.Columns.Add(bf);
                        }
                    }
                    this.gvInventory.Width = Unit.Parse(gvWidth.ToString());
                    base.BindData2GridView(this.gvInventory, ds);
                    if ((ds != null) && (ds.Tables.Count > 1))
                    {
                        this.PagerFooter.PageInfo = ds.Tables[1].Rows[0]["CurrentPage"].ToString() + " / " + ds.Tables[1].Rows[0]["TotalPagesCount"].ToString() + "&nbsp;&nbsp;&nbsp;共: " + ds.Tables[1].Rows[0]["TotalRecordsCount"].ToString();
                        this.PagerFooter.TotalPages = int.Parse(ds.Tables[1].Rows[0]["TotalPagesCount"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F5050_001") + ex.Message;
                this.lblMsg.Visible = true;
            }
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
            inventoryQuery.IsGetAll = true;
            this.hdnActionID.Value = "Y";
            string currentPageIndex = inventoryQuery.CurrentPage;
            inventoryQuery.CurrentPage = "0";
            this.gvInventory.AllowSorting = false;
            this.BindData2InventoryList(inventoryQuery);
            this.hdnActionID.Value = "";
            this.gvInventory.ShowFooter = false;
            inventoryQuery.IsGetAll = false;
            inventoryQuery.CurrentPage = currentPageIndex;
            this.SetInventoryQueryEntity(inventoryQuery);
            base.Export2Excel("Inventory.xls", this.gvInventory);
        }

        protected void btnFirst_Click(object sender, EventArgs e)
        {
            InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
            inventoryQuery.CurrentPage = "0";
            this.BindData2InventoryList(inventoryQuery);
        }

        protected void btnLast_Click(object sender, EventArgs e)
        {
            InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
            inventoryQuery.CurrentPage = (this.PagerFooter.TotalPages - 1).ToString();
            this.BindData2InventoryList(inventoryQuery);
        }

        protected void btnNext_Click(object sender, EventArgs e)
        {
            InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
            if (int.Parse(inventoryQuery.CurrentPage) < (this.PagerFooter.TotalPages - 1))
            {
                inventoryQuery.CurrentPage = (int.Parse(inventoryQuery.CurrentPage) + 1).ToString();
                this.BindData2InventoryList(inventoryQuery);
            }
        }

        protected void btnPrevious_Click(object sender, EventArgs e)
        {
            InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
            if (int.Parse(inventoryQuery.CurrentPage) > 0)
            {
                inventoryQuery.CurrentPage = (int.Parse(inventoryQuery.CurrentPage) - 1).ToString();
                this.BindData2InventoryList(inventoryQuery);
            }
        }

        private InventoryQueryEntity GetInventoryQueryEntity()
        {
            if (!string.IsNullOrEmpty(this.hdnActionID.Value))
            {
                return (base.PageQueryEntityViewState as InventoryQueryEntity);
            }
            return (base.PageQueryEntitySession as InventoryQueryEntity);
        }

        private string GetStrByDicKey(string strKey)
        {
            string temp = string.Empty;
            if (base.UserInfo.Preference.Lang.ToLower() == "zh-cn")
            {
                if (this.dicColum.ContainsKey(strKey.ToUpper()))
                {
                    temp = this.dicColum[strKey].ToString();
                }
                return temp;
            }
            if (base.UserInfo.Preference.Lang.ToLower() == "en-*")
            {
                if (this.dicColum2.ContainsKey(strKey.ToUpper()))
                {
                    temp = this.dicColum2[strKey].ToString();
                }
                return temp;
            }
            if ((base.UserInfo.Preference.Lang.ToLower() == "zh-tw") && this.dicColum3.ContainsKey(strKey.ToUpper()))
            {
                temp = this.dicColum3[strKey].ToString();
            }
            return temp;
        }

        protected void GoTo_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(((TextBox) this.PagerFooter.FindControl("txtGo2Page")).Text.Trim()))
            {
                InventoryQueryEntity inventoryQuery = this.GetInventoryQueryEntity();
                inventoryQuery.CurrentPage = this.PagerFooter.GoToPage.ToString();
                this.BindData2InventoryList(inventoryQuery);
            }
        }

        protected void gvInventory_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[0].Text = (((this.PagerFooter.CurrentPage * this.PagerFooter.PageSize) + e.Row.RowIndex) + 1).ToString();
                e.Row.Attributes.Add("onmouseout", "GridViewRowMouseout(this);");
                e.Row.Attributes.Add("onmouseover", "GridViewRowMouseover(this);");
                ((CheckBox) e.Row.FindControl("chbSelect")).Attributes.Add("onclick", "GridViewCheckBoxClick('" + e.Row.ClientID + "')");
                e.Row.Attributes.Add("ondblclick", "JavaScript:document.getElementById('" + ((CheckBox) e.Row.FindControl("chbSelect")).ClientID + "').click();");
                this.InitPreferenceDigit(e.Row);
            }
        }

        private void InitPreferenceDigit(GridViewRow gvr)
        {
            switch (base.Request.QueryString["Condition"])
            {
                case "1":
                    gvr.Cells[6].Text = base.GetPreferenceDigit(gvr.Cells[6].Text);
                    gvr.Cells[7].Text = base.GetPreferenceDigit(gvr.Cells[7].Text);
                    gvr.Cells[8].Text = base.GetPreferenceDigit(gvr.Cells[8].Text);
                    gvr.Cells[8].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[8].ClientID + "','Allocated','" + gvr.Cells[2].Text + "','" + gvr.Cells[3].Text + "','','','');");
                    gvr.Cells[8].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[8].CssClass = "linklabel";
                    gvr.Cells[9].Text = base.GetPreferenceDigit(gvr.Cells[9].Text);
                    gvr.Cells[10].Text = base.GetPreferenceDigit(gvr.Cells[10].Text);
                    gvr.Cells[11].Text = base.GetPreferenceDigit(gvr.Cells[11].Text);
                    gvr.Cells[12].Text = base.GetPreferenceDigit(gvr.Cells[12].Text);
                    gvr.Cells[12].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[12].ClientID + "','Preallocated','" + gvr.Cells[2].Text + "','" + gvr.Cells[3].Text + "','','','');");
                    gvr.Cells[12].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[12].CssClass = "linklabel";
                    break;

                case "2":
                    gvr.Cells[7].Text = base.GetPreferenceDigit(gvr.Cells[7].Text);
                    gvr.Cells[8].Text = base.GetPreferenceDigit(gvr.Cells[8].Text);
                    gvr.Cells[9].Text = base.GetPreferenceDigit(gvr.Cells[9].Text);
                    gvr.Cells[9].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[8].ClientID + "','Allocated','" + gvr.Cells[2].Text + "','" + gvr.Cells[3].Text + "','','" + gvr.Cells[6].Text + "','');");
                    gvr.Cells[9].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[9].CssClass = "linklabel";
                    gvr.Cells[10].Text = base.GetPreferenceDigit(gvr.Cells[10].Text);
                    gvr.Cells[11].Text = base.GetPreferenceDigit(gvr.Cells[11].Text);
                    gvr.Cells[12].Text = base.GetPreferenceDigit(gvr.Cells[12].Text);
                    gvr.Cells[13].Text = base.GetPreferenceDigit(gvr.Cells[13].Text);
                    break;

                case "3":
                    gvr.Cells[3].Text = base.GetPreferenceDigit(gvr.Cells[3].Text);
                    break;

                case "4":
                    gvr.Cells[7].Text = base.GetPreferenceDigit(gvr.Cells[7].Text);
                    gvr.Cells[8].Text = base.GetPreferenceDigit(gvr.Cells[8].Text);
                    gvr.Cells[9].Text = base.GetPreferenceDigit(gvr.Cells[9].Text);
                    break;

                case "5":
                    gvr.Cells[7].Text = base.GetPreferenceDigit(gvr.Cells[7].Text);
                    gvr.Cells[8].Text = base.GetPreferenceDigit(gvr.Cells[8].Text);
                    gvr.Cells[9].Text = base.GetPreferenceDigit(gvr.Cells[9].Text);
                    gvr.Cells[9].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[8].ClientID + "','Allocated','" + gvr.Cells[3].Text + "','" + gvr.Cells[4].Text + "','" + gvr.Cells[2].Text + "','','');");
                    gvr.Cells[9].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[9].CssClass = "linklabel";
                    gvr.Cells[10].Text = base.GetPreferenceDigit(gvr.Cells[10].Text);
                    gvr.Cells[10].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[10].ClientID + "','Preallocated','" + gvr.Cells[3].Text + "','" + gvr.Cells[4].Text + "','" + gvr.Cells[2].Text + "','','');");
                    gvr.Cells[10].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[10].CssClass = "linklabel";
                    gvr.Cells[11].Text = base.GetPreferenceDigit(gvr.Cells[11].Text);
                    gvr.Cells[12].Text = base.GetPreferenceDigit(gvr.Cells[12].Text);
                    break;

                case "6":
                    gvr.Cells[4].Text = base.GetPreferenceDigit(gvr.Cells[4].Text);
                    break;

                case "7":
                    gvr.Cells[8].Text = base.GetPreferenceDigit(gvr.Cells[8].Text);
                    break;

                case "8":
                    gvr.Cells[9].Text = base.GetPreferenceDigit(gvr.Cells[9].Text);
                    gvr.Cells[10].Text = base.GetPreferenceDigit(gvr.Cells[10].Text);
                    gvr.Cells[12].Text = base.GetPreferenceDigit(gvr.Cells[12].Text);
                    gvr.Cells[12].Attributes.Add("onclick", "GetOrderDateAjax('" + gvr.Cells[8].ClientID + "','Allocated','" + gvr.Cells[2].Text + "','" + gvr.Cells[3].Text + "','" + gvr.Cells[6].Text + "','" + gvr.Cells[8].Text + "','" + gvr.Cells[7].Text + "');");
                    gvr.Cells[12].Attributes.Add("style", "cursor:hand;");
                    gvr.Cells[12].CssClass = "linklabel";
                    gvr.Cells[13].Text = base.GetPreferenceDigit(gvr.Cells[13].Text);
                    gvr.Cells[14].Text = base.GetPreferenceDigit(gvr.Cells[14].Text);
                    gvr.Cells[15].Text = base.GetPreferenceDigit(gvr.Cells[15].Text);
                    break;

                case "9":
                    gvr.Cells[3].Text = base.GetPreferenceDigit(gvr.Cells[3].Text);
                    gvr.Cells[4].Text = base.GetPreferenceDigit(gvr.Cells[4].Text);
                    gvr.Cells[5].Text = base.GetPreferenceDigit(gvr.Cells[5].Text);
                    break;
            }
        }

        private void LoadDataToGridView()
        {
            InventoryQueryEntity inventoryQuery = new InventoryQueryEntity();
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                string strCondition = base.Request.QueryString["Condition"].ToString();
                if (this.PreviousPage != null)
                {
                    inventoryQuery.OwnerID = this.PreviousPage.OwnerID;
                    inventoryQuery.Sku = this.PreviousPage.Sku;
                    inventoryQuery.LotAttributeID = this.PreviousPage.LotAttributeID;
                    inventoryQuery.Location = this.PreviousPage.Loaction;
                    inventoryQuery.LPN = this.PreviousPage.Lpn;
                    inventoryQuery.Descr = this.PreviousPage.SkuDescr;
                    inventoryQuery.SkuClassID = this.PreviousPage.SkuClassID;
                    inventoryQuery.LotAttribute9 = this.PreviousPage.SkuProperty;
                    if (this.PreviousPage.History == "N")
                    {
                        inventoryQuery.QTY = " > 0";
                    }
                    inventoryQuery.LotAttribute1 = this.PreviousPage.LotAttribute01;
                    inventoryQuery.LotAttribute2 = this.PreviousPage.LotAttribute02;
                    inventoryQuery.LotAttribute3 = this.PreviousPage.LotAttribute03;
                    inventoryQuery.LotAttribute4 = this.PreviousPage.LotAttribute04;
                    inventoryQuery.LotAttribute5 = this.PreviousPage.LotAttribute05;
                    inventoryQuery.LotAttribute6 = this.PreviousPage.LotAttribute06;
                    inventoryQuery.LotAttribute7 = this.PreviousPage.LotAttribute07;
                    inventoryQuery.LotAttribute8 = this.PreviousPage.LotAttribute08;
                    inventoryQuery.LotAttribute10 = this.PreviousPage.LotAttribute10;
                    inventoryQuery.ProductDate = this.PreviousPage.ProductDate;
                    inventoryQuery.ExpiryDate = this.PreviousPage.ExpiryDate;
                    inventoryQuery.ReceiptDate = this.PreviousPage.ReceiptDate;
                    inventoryQuery.ExternalLot = this.PreviousPage.ExternalLot;
                    inventoryQuery.VendorID = this.PreviousPage.VendorID;
                }
                inventoryQuery.Condition = strCondition;
            }
            else
            {
                this.hdnFrom.Value = base.Request.QueryString["from"].ToString();
            }
            inventoryQuery.IsGetAll = false;
            inventoryQuery.CurrentPage = "0";
            inventoryQuery.PageSize = this.gvInventory.PageSize.ToString();
            this.PagerFooter.PageSize = this.gvInventory.PageSize;
            if (!string.IsNullOrEmpty(base.Request.QueryString["export"]))
            {
                this.hdnActionID.Value = base.Request.QueryString["export"];
            }
            this.SetInventoryQueryEntity(inventoryQuery);
            this.BindData2InventoryList(inventoryQuery);
            if (!string.IsNullOrEmpty(base.Request.QueryString["export"]))
            {
                this.btnExport_Click(null, null);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.UserInfo.Preference.Lang.ToLower() == "zh-cn")
            {
                this.hstable = new Hashtable();
                this.dicColum = new Dictionary<string, string>();
                if (base.Cache["InventoryQueryHeaderText"] != null)
                {
                    this.dicColum = base.Cache["InventoryQueryHeaderText"] as Dictionary<string, string>;
                }
                else
                {
                    this.dicColum.Add("OWNER_ID", "货主代码");
                    this.dicColum.Add("SKU_ID", "货品代码");
                    this.dicColum.Add("DESCR", "货品描述");
                    this.dicColum.Add("DESCR2", "货品描述2");
                    this.dicColum.Add("SKU_PROPERTY", "货品属性");
                    this.dicColum.Add("SKU_CLASS_ID", "货品分类");
                    this.dicColum.Add("SKU_CLASS_DESCR", "货品分类描述");
                    this.dicColum.Add("SKU_CLASS_DESCR2", "货品分类描述2");
                    this.dicColum.Add("QTY", "现有");
                    this.dicColum.Add("PICKED_QTY", "已拣货");
                    this.dicColum.Add("AVAILABLE", "可用");
                    this.dicColum.Add("ALLOCATED_QTY", "已分配");
                    this.dicColum.Add("ONHOLD_QTY", "冻结");
                    this.dicColum.Add("PREALLOCATED_QTY", "预分配");
                    this.dicColum.Add("LOC", "货位");
                    this.dicColum.Add("LOCATION", "货位");
                    this.dicColum.Add("QTY_LOCATION_MINIMUM", "容量(上限)");
                    this.dicColum.Add("QTY_LOCATION_LIMIT", "容量(下限)");
                    this.dicColum.Add("LOCATION_TYPE", "货位类型");
                    this.dicColum.Add("LPN", "LPN");
                    this.dicColum.Add("LPN_ID", "LPN");
                    this.dicColum.Add("STATUS", "状态");
                    this.dicColum.Add("PACK_ID", "包装");
                    this.dicColum.Add("PALLET_TI", "每层箱数");
                    this.dicColum.Add("PALLET_HI", "层数");
                    this.dicColum.Add("CUBEONHAND", "已用容积");
                    this.dicColum.Add("CUBIC_CAPACIT", "容积");
                    this.dicColum.Add("CUBE_AVAILABLE", "可用容积");
                    this.dicColum.Add("CUBE_ONHAND_PERCENTAGE", "所用百分率");
                    this.dicColum.Add("LOT", "批次号");
                    this.dicColum.Add("EXTERNAL_LOT", "外部批号");
                    this.dicColum.Add("LOT_ATTR01", "批次属性01");
                    this.dicColum.Add("LOT_ATTR02", "批次属性02");
                    this.dicColum.Add("LOT_ATTR03", "批次属性03");
                    this.dicColum.Add("LOT_ATTR04", "批次属性04");
                    this.dicColum.Add("LOT_ATTR05", "批次属性05");
                    this.dicColum.Add("LOT_ATTR06", "批次属性06");
                    this.dicColum.Add("LOT_ATTR07", "批次属性07");
                    this.dicColum.Add("LOT_ATTR08", "批次属性08");
                    this.dicColum.Add("LOT_ATTR09", "批次属性09");
                    this.dicColum.Add("LOT_ATTR10", "批次属性10");
                    this.dicColum.Add("PRODUCE_DATE", "生产日期");
                    this.dicColum.Add("EXPIRY_DATE", "失效日期");
                    this.dicColum.Add("RECEIPT_DATE", "入库日期");
                    this.dicColum.Add("VENDOR_ID", "供应商代码");
                    this.dicColum.Add("PICKINPROCESS_QTY", "正在拣货");
                    this.dicColum.Add("PENDING_MOVE_IN", "等待上架");
                    base.Cache["InventoryQueryHeaderText"] = this.dicColum;
                }
            }
            else if (base.UserInfo.Preference.Lang.ToLower() == "en-*")
            {
                this.dicColum2 = new Dictionary<string, string>();
                if (base.Cache["InventoryQueryHeaderText_en"] != null)
                {
                    this.dicColum2 = base.Cache["InventoryQueryHeaderText_en"] as Dictionary<string, string>;
                }
                else
                {
                    this.dicColum2.Add("OWNER_ID", "Owner ID");
                    this.dicColum2.Add("SKU_ID", "Sku ID");
                    this.dicColum2.Add("DESCR", "Description");
                    this.dicColum2.Add("DESCR2", "Description2");
                    this.dicColum2.Add("SKU_PROPERTY", "Sku Property");
                    this.dicColum2.Add("SKU_CLASS_ID", "Sku Class ID");
                    this.dicColum2.Add("SKU_CLASS_DESCR", "Sku Class Descr");
                    this.dicColum2.Add("SKU_CLASS_DESCR2", "Sku Class Descr2");
                    this.dicColum2.Add("QTY", "Qty");
                    this.dicColum2.Add("PICKED_QTY", "Picked Qty");
                    this.dicColum2.Add("AVAILABLE", "Available Qty");
                    this.dicColum2.Add("ALLOCATED_QTY", "Allocated Qty");
                    this.dicColum2.Add("ONHOLD_QTY", "Onhold Qty");
                    this.dicColum2.Add("PREALLOCATED_QTY", "Preallocated Qty");
                    this.dicColum2.Add("LOC", "Location");
                    this.dicColum2.Add("LOCATION", "Location");
                    this.dicColum2.Add("QTY_LOCATION_MINIMUM", "Min Location Qty");
                    this.dicColum2.Add("QTY_LOCATION_LIMIT", "Location Qty Limit");
                    this.dicColum2.Add("LOCATION_TYPE", "Location Type");
                    this.dicColum2.Add("LPN", "LPN");
                    this.dicColum2.Add("LPN_ID", "LPN");
                    this.dicColum2.Add("STATUS", "Status");
                    this.dicColum2.Add("PACK_ID", "Pack ID");
                    this.dicColum2.Add("PALLET_TI", "Pallet TI");
                    this.dicColum2.Add("PALLET_HI", "Pallet HI");
                    this.dicColum2.Add("CUBEONHAND", "Cube Onhand");
                    this.dicColum2.Add("CUBIC_CAPACIT", "Cube Capacit");
                    this.dicColum2.Add("CUBE_AVAILABLE", "Cube Available");
                    this.dicColum2.Add("CUBE_ONHAND_PERCENTAGE", "Cube Onhand Percentage");
                    this.dicColum2.Add("LOT", "Lot");
                    this.dicColum2.Add("EXTERNAL_LOT", "External Lot");
                    this.dicColum2.Add("LOT_ATTR01", "Lotattribute01");
                    this.dicColum2.Add("LOT_ATTR02", "Lotattribute02");
                    this.dicColum2.Add("LOT_ATTR03", "Lotattribute03");
                    this.dicColum2.Add("LOT_ATTR04", "Lotattribute04");
                    this.dicColum2.Add("LOT_ATTR05", "Lotattribute05");
                    this.dicColum2.Add("LOT_ATTR06", "Lotattribute06");
                    this.dicColum2.Add("LOT_ATTR07", "Lotattribute07");
                    this.dicColum2.Add("LOT_ATTR08", "Lotattribute08");
                    this.dicColum2.Add("LOT_ATTR09", "Lotattribute09");
                    this.dicColum2.Add("LOT_ATTR10", "Lotattribute10");
                    this.dicColum2.Add("PRODUCE_DATE", "Produce Date");
                    this.dicColum2.Add("EXPIRY_DATE", "Expiry Date");
                    this.dicColum2.Add("RECEIPT_DATE", "Receipt Date");
                    this.dicColum2.Add("VENDOR_ID", "Vendor ID");
                    this.dicColum2.Add("PICKINPROCESS_QTY", "Picking Process Qty");
                    this.dicColum2.Add("PENDING_MOVE_IN", "Pending Move In");
                    base.Cache["InventoryQueryHeaderText_en"] = this.dicColum2;
                }
            }
            else if (base.UserInfo.Preference.Lang.ToLower() == "zh-tw")
            {
                this.dicColum3 = new Dictionary<string, string>();
                if (base.Cache["InventoryQueryHeaderText_tw"] != null)
                {
                    this.dicColum3 = base.Cache["InventoryQueryHeaderText_tw"] as Dictionary<string, string>;
                }
                else
                {
                    this.dicColum3.Add("OWNER_ID", "貨主");
                    this.dicColum3.Add("SKU_ID", "貨品");
                    this.dicColum3.Add("DESCR", "貨品描述");
                    this.dicColum3.Add("DESCR2", "貨品描述2");
                    this.dicColum3.Add("SKU_PROPERTY", "貨品屬性");
                    this.dicColum3.Add("SKU_CLASS_ID", "貨品分類");
                    this.dicColum3.Add("SKU_CLASS_DESCR", "貨品分類描述");
                    this.dicColum3.Add("SKU_CLASS_DESCR2", "貨品分類描述2");
                    this.dicColum3.Add("QTY", "現有");
                    this.dicColum3.Add("PICKED_QTY", "已揀貨");
                    this.dicColum3.Add("AVAILABLE", "可用");
                    this.dicColum3.Add("ALLOCATED_QTY", "已分配");
                    this.dicColum3.Add("ONHOLD_QTY", "凍結");
                    this.dicColum3.Add("PREALLOCATED_QTY", "預分配");
                    this.dicColum3.Add("LOC", "儲位");
                    this.dicColum3.Add("LOCATION", "儲位");
                    this.dicColum3.Add("QTY_LOCATION_MINIMUM", "容量(上限)");
                    this.dicColum3.Add("QTY_LOCATION_LIMIT", "容量(下限)");
                    this.dicColum3.Add("LOCATION_TYPE", "儲位類型");
                    this.dicColum3.Add("LPN", "LPN");
                    this.dicColum3.Add("LPN_ID", "LPN");
                    this.dicColum3.Add("STATUS", "狀態");
                    this.dicColum3.Add("PACK_ID", "包裝");
                    this.dicColum3.Add("PALLET_TI", "每層箱數");
                    this.dicColum3.Add("PALLET_HI", "層數");
                    this.dicColum3.Add("CUBEONHAND", "已用容積");
                    this.dicColum3.Add("CUBIC_CAPACIT", "容積");
                    this.dicColum3.Add("CUBE_AVAILABLE", "可用容積");
                    this.dicColum3.Add("CUBE_ONHAND_PERCENTAGE", "所用百分率");
                    this.dicColum3.Add("LOT", "批次號");
                    this.dicColum3.Add("EXTERNAL_LOT", "外部批號");
                    this.dicColum3.Add("LOT_ATTR01", "批次屬性01");
                    this.dicColum3.Add("LOT_ATTR02", "批次屬性02");
                    this.dicColum3.Add("LOT_ATTR03", "批次屬性03");
                    this.dicColum3.Add("LOT_ATTR04", "批次屬性04");
                    this.dicColum3.Add("LOT_ATTR05", "批次屬性05");
                    this.dicColum3.Add("LOT_ATTR06", "批次屬性06");
                    this.dicColum3.Add("LOT_ATTR07", "批次屬性07");
                    this.dicColum3.Add("LOT_ATTR08", "批次屬性08");
                    this.dicColum3.Add("LOT_ATTR09", "批次屬性09");
                    this.dicColum3.Add("LOT_ATTR10", "批次屬性10");
                    this.dicColum3.Add("PRODUCE_DATE", "生產日期");
                    this.dicColum3.Add("EXPIRY_DATE", "失效日期");
                    this.dicColum3.Add("RECEIPT_DATE", "入庫日期");
                    this.dicColum3.Add("VENDOR_ID", "供應商代碼");
                    this.dicColum3.Add("PICKINPROCESS_QTY", "正在揀貨");
                    this.dicColum3.Add("PENDING_MOVE_IN", "等待上架");
                    base.Cache["InventoryQueryHeaderText_en"] = this.dicColum3;
                }
            }
            if (!base.IsPostBack && !string.IsNullOrEmpty(base.Request.QueryString["Condition"]))
            {
                base.InitPage(this.Page);
                base.InitAnalyticsReportGridview(this.gvInventory);
                this.LoadDataToGridView();
            }
        }

        private void SetInventoryQueryEntity(InventoryQueryEntity inventoryQueryEntity)
        {
            if (!string.IsNullOrEmpty(this.hdnActionID.Value))
            {
                base.PageQueryEntityViewState = inventoryQueryEntity;
            }
            else
            {
                base.PageQueryEntitySession = inventoryQueryEntity;
            }
        }

        public InventoryQuery PreviousPage
        {
            get
            {
                return (InventoryQuery) base.PreviousPage;
            }
        }
    }
}

